<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'document.label', default: 'document')}"/>
    <title>编辑帮助文档</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>编辑帮助文档</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="document" action="index">帮助文档列表</g:link>
                    </li>
                    <li class="breadcrumb-item">编辑帮助文档</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${this.document}">
                <ul class="errors" role="alert">
                    <g:eachError bean="${this.document}" var="error">
                        <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                                error="${error}"/></li>
                    </g:eachError>
                </ul>
            </g:hasErrors>
            <div class="card">
                <div class="card-header">
                    <h5>编辑帮助文档信息</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <g:form resource="${this.document}" method="PUT"  class="documentForm">

                        <div class="form-group row">
                            <label class="col-md-2 control-label">标题</label>

                            <div class="col-md-3">
                                <g:textField name="title" value="${this.document?.title}" required="" maxlength="128"
                                             class="form-control"/>
                            </div>
                            <label class="col-md-3 control-label">是否使用</label>

                            <div class="col-md-2 border-checkbox-section">
                                <div class="border-checkbox-group border-checkbox-group-primary form-control-static">
                                    <g:checkBox class="border-checkbox" name="active" id="checkbox0"
                                                value="${this.document?.active}"/>
                                    <label class="border-checkbox-label" for="checkbox0"></label>
                                </div>

                            </div>
                        </div>

                        <div class="form-group row">
                            <g:field name="document" id="document"
                                     value="${this.document?.document}"
                                     type="hidden"/>
                            <label class="col-md-2 control-label">帮助文档</label>
                            <div class="col-md-10">
                                <div id="summernote">${this.document?.document}</div>
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-12">
                                <button type="button" class="btn btn-info" id="documentBtn">保存</button>

                            </div>
                        </div>
                    </g:form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        var text = $("#document").val();
        $('#summernote').summernote({
            minHeight: 200,
            maxHeight: 500,

        }).summernote('code', text);

        $("#documentBtn").click(function () {
            var markupStr = $('#summernote').summernote('code');
            $("#document").val(markupStr);
            $(".documentForm").submit();
        });
    })
</script>
</body>

</html>

